<?php
/* @var $this TurmaController */
/* @var $model Turma */
/* @var $form CActiveForm */
?>

<div class="form">

	<?php $form=$this->beginWidget('CActiveForm', array(
			'id'=>'turma-form',
			// Please note: When you enable ajax validation, make sure the corresponding
			// controller action is handling ajax validation correctly.
			// There is a call to performAjaxValidation() commented in generated controller code.
			// See class documentation of CActiveForm for details on this.
			'enableAjaxValidation'=>false,
)); ?>

	<p class="note">
		Campos com <span class="required">*</span> são Obrigatórios.
	</p>

	<?php echo $form->errorSummary($model); ?>

	<div class="row">
		<span style="float: left; width: 500px;"> <?php echo $form->labelEx($model,'nome'); ?>
			<?php echo $form->textField($model,'nome',array('class'=>'span6','size'=>45,'maxlength'=>45)); ?>
			<?php echo $form->error($model,'nome'); ?>
		</span>
	</div>
	<div class="row">
		<span style="float: left; width: 500px;"> <?php 
		$funcionarios = Funcionario::model()->findAllByAttributes(array('polo_id' => Yii::app()->session['polo_id']));
		$data = array();
		foreach ($funcionarios as $funcionario) {
			$pessoa = Pessoa::model()->findByAttributes(array('id'=>$funcionario->pessoa_id));
			if($funcionario->id != 1) {
				$data[$funcionario->id] = $pessoa->nome;
			}
		} ?> <?php echo $form->labelEx($model,'responsavel_id'); ?> <?php echo $form->dropDownList($model, 'responsavel_id', $data, array('class'=>'span6','empty' => '')); ?>
		</span>
	</div>
	<div class="row">
		<span style="float: left; width: 300px;"> <?php echo $form->labelEx($model,'classe_id'); ?>
			<?php 
			$list = Classe::model()->findAll(array(), array('id','nome'));
			$result = array();
			$position = 1;
			foreach($list as $class) {
				$result[(string)$class->id] = (string)$class->nome;
				$position++;
			}
			echo $form->dropDownList($model,'classe_id', $result , array('empty' => ''));
			?>
		</span>
		<span style="float: left; width: 300px;"> <?php echo $form->labelEx($model,'ano'); ?>
			<?php
			$yearNow = date("Y");
			$yearFrom = $yearNow - 10;
			$yearTo = $yearNow + 5;
			$arrYears = array();
    	 
		 	foreach (range($yearFrom, $yearTo) as $number) {
		 	$arrYears[$number] = $number; 
		 }

			$arrYears = array_reverse($arrYears, true);
		 
			echo $form->dropDownList($model,'ano',$arrYears, array('empty'=>''));?> 
			<?php echo $form->error($model,'ano'); ?>
		</span> 
	</div>
	<div class="row">
		<span style="float: left; width: 300px;"> <?php echo $form->labelEx($model,'vagas'); ?>
			<?php echo $form->textField($model,'vagas'); ?> <?php echo $form->error($model,'vagas'); ?>
		</span>
	
		<span style="float: left; width: 300px;"> <?php 
		$turno_list = Caracteristica::model()->findAllByAttributes(array('tipo'=>'Horario'));
		$turnos = array();
		foreach ($turno_list as $turno) {
			$turnos[$turno->nome] = $turno->nome;
		}
		?> <?php echo $form->labelEx($model, 'turno')?> <?php echo $form->dropDownList($model, 'turno', $turnos, array('empty' => '')); ?>
			<?php echo $form->error($model, 'turno')?>
		</span>
	</div>

<div align="center" class="form-actions">
	<?php $this->widget('bootstrap.widgets.TbButton', array(
			'buttonType'=>'submit',
			'type'=>'primary',
			'label'=>$model->isNewRecord ? 'Cadastrar' : 'Salvar',
		)); ?>
</div>

	<?php $this->endWidget(); ?>

</div>
<!-- form -->
